<?php
session_start();
include "Includes/solotrn_sesion.php";
include "Includes/soloFun_Generales.php";

$Nodo = $_REQUEST["CboNodos"];
$strcodi = $_REQUEST["txtCodigo"];
$txtnombre = $_REQUEST["txtNombre"];
$SoloPerfil = $_REQUEST["xtxtperfil"];
$SoloMail = $_REQUEST["mail"];
$SoloFono = $_REQUEST["telefono"];
$SoloExtension = $_REQUEST["extension"];
$SoloCelular = $_REQUEST["celular"];
$Opcion = $_REQUEST["Opcion"];

switch ($Opcion) {
    case 1:
        $tipo = "UPDATE";
        $tabla = "solotb_usuario_infoadic";
        $strSQL = "$tipo $tabla set ";
        $strSQL .= "perfil='$SoloPerfil',";
        $strSQL .= "mail='$SoloMail',";
        $strSQL .= "telefono='$Solofono',";
        $strSQL .= "extension='$SoloExtension',";
        $strSQL .= "celular='$SoloCelular'";
        $strSQL .= " where nu_usua=" . $strcodi;

        $pagina = "solotrn_IngresarUsuarioInfoAdicional.php";
        $opc = "&txtCodigo=$strcodi&txtNombre=$txtnombre&Opcion=1";
        break;

    case 2:
        $tipo = "DELETE";
        $tabla = "solotb_usuario_infoadic";
        $strSQL = "$tipo from $tabla ";
        $strSQL .= " where nu_usua=" . $strcodi;
        $pagina = "solotrn_IngresarUsuarioInfoAdicional.php";
        $opc = "&txtCodigo=$strcodi&txtNombre=$txtnombre&Opcion=2";
        break;
    default:
        $tipo = "INSERT";
        $tabla = "solotb_usuario_infoadic";
        $strSQL="$tipo into $tabla values(";
        $strSQL .= $strcodi.",";
        $strSQL .= $Nodo . ",";
        $strSQL .= "'$SoloPerfil',";
        $strSQL .= "NULL,";
        $strSQL .= "NULL,";
        $strSQL .= "NULL,";
        $strSQL .= "'$SoloMail',";
        $strSQL .= "'$Solofono',";
        $strSQL .= "'$oloExtension',";
        $strSQL .= "'$SoloCelular',";
        $strSQL .= "NULL,";
        $strSQL .= "NULL,";
        $strSQL .= "NULL)";
//echo $strSQL;
        //'re
        $pagina = "solotrn_IngresarUsuarioInfoAdicional.php";
        $opc = "&txtCodigo=$strcodi&txtNombre=$txtnombre&Opcion=3";
        break;
}
//'response.write strSQL
//'re
$arrQueries = array();
array_push($arrQueries, $strSQL);
array_push($arrQueries, crearQueryLog($tabla, $tipo, $strSQL));

$oConexion = new Conexion($WORKFLOW["motor_base"], $WORKFLOW["db_usuario"], $WORKFLOW["db_password"],
        $WORKFLOW["basedatos"], $WORKFLOW["servidor"], $WORKFLOW["flags"], $WORKFLOW["encoding"]);

//if (!$oConexion->EjecutarQuery($strSQL)) {
if (!$oConexion->EjecutarTransaccion($arrQueries)) {
    $strMsg = $pagina . "?SoloError=1" . $opc;
    echo $oConexion->getErrorMessage();
    $oConexion->Cerrar();
    return;
}else
    $strMsg = $pagina . "?SoloError=0" . $opc;

$oConexion->Cerrar();
header ("Location: $strMsg");
?>